package com.example.dmcommom.Enum;

import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author yym
 */

@Getter
public enum ElectricityTimeCategoryEnum {

	sharp(0, "尖", Collections.emptyList()),
	peek(1, "峰", Arrays.asList("高", "高峰")),
	shoulder(2, "平", Collections.singletonList("平时")),
	off_peek(3, "谷", Arrays.asList("低", "低谷")),
	ravine(4, "深谷", Collections.singletonList("深"));


	private final int id;

	private final String name;

	private final List<String> subname;

	ElectricityTimeCategoryEnum(int i, String name, List<String> subname) {
		this.id = i;
		this.name = name;
		this.subname = subname;
	}

	public static ElectricityTimeCategoryEnum fromString(String text) {
		for (ElectricityTimeCategoryEnum e : ElectricityTimeCategoryEnum.values()) {
			if (e.getName().equals(text)) {
				return e;
			}
			if (!e.getSubname().isEmpty()) {
				if (e.getSubname().contains(text)) {
					return e;
				}
			}
		}
		return null;
	}
}
